var teamId;
var tmScoreListId;
var tmScoreList={};
$(document).ready(function(){ 
	$('#header').animate({'top':'0px'},400);
	teamId = args.teamId; //取得id的值
	tmScoreListId=args.tmScoreListId;
	if(tmScoreListId!=undefined){
		$.getJSON(path+"/soccer/tmScoreListAction!selectById.action",{tmScoreListId: tmScoreListId}, function(data){
			tmScoreList=data.tmScoreList;
			$("#tmScoreListId").val(tmScoreListId);
			$("#listName").val(tmScoreList.listName);
			$("#gameDataFlag").val(tmScoreList.gameDataFlag);
			$("#disciplineFlag").val(tmScoreList.disciplineFlag);
			$("#startDate").val(moment(tmScoreList.startDate,"YYYY-MM-DD").format("YYYY-MM-DD"));
			$("#endDate").val(moment(tmScoreList.endDate,"YYYY-MM-DD HH:mm:ss").format("YYYY-MM-DD"));
			$("#remark").val(tmScoreList.remark);
		});
	}else{
		//新增初始化
	}
	
	$("#submitBtn").click(function(){
		var strMessage="";
		//检查必填
		if($("input[id='listName']").val()==undefined||$.trim($("input[id='listName']").val())==""){
			strMessage += "榜单名称必填!";
			alert(strMessage);
			return false;
		}
		if($("#startDate").val()==undefined||$.trim($("#startDate").val())==""){
			strMessage += "开始日期必填!";
			alert(strMessage);
			return false;
		}
		if($("#endDate").val()==undefined||$.trim($("#endDate").val())==""){
			strMessage += "截止日期必填!";
			alert(strMessage);
			return false;
		}
		//检查必填结束
		tmScoreList.teamId=teamId;
		tmScoreList.listName=$("input[id='listName']").val();
		tmScoreList.gameDataFlag=$("#gameDataFlag option:selected").val();
		tmScoreList.disciplineFlag=$("#disciplineFlag option:selected").val();
		tmScoreList.startDate=$("#startDate").val();
		tmScoreList.endDate=$("#endDate").val();
		tmScoreList.remark=$("input[id='remark']").val();
		var jsonStr = JSON.stringify(tmScoreList);
		var postData={jsonStr:jsonStr};
		$.post(path+"/soccer/tmScoreListAction!saveTmScoreList.action",postData, function(data){
//			strMessage = data.strMessage;
//			$('#strMessage').text(strMessage);
			goBack();
		},'json');
	});
});
function goBack(){
	var timestamp = (new Date()).valueOf();
	window.location.href=path+"/soccer/teamScoreList.jsp?teamId="+teamId+"&timestamp="+timestamp;
}
